//package com.poi.java.util;
//
//import java.io.FileInputStream;
//
//import java.io.FileOutputStream;
//
//import java.io.IOException;
//import java.util.List;
//
//import org.apache.poi.xwpf.usermodel.XWPFDocument;
//
//import org.apache.poi.xwpf.usermodel.XWPFParagraph;
//
//import org.apache.poi.xwpf.usermodel.XWPFRun;
//
//public class WordUtils11 {
//    /**
//     * 设置使用的编码格式
//     */
//    private static final String CHARSET = "UTF-8";
//    /**
//     * 设置使用的版本
//     */
//    private static final String VERSION = "2.3.0";
//
//    public static void main(String[] args) {
//
//
//        String filePath = "D:\\test.docx";//要打开的Word文档的路径  String oldStr = "要替换的关键词";
//
//        String newStr = "替换后的新关键词";
//
//        FileInputStream in = null;
//
//        XWPFDocument doc = null;
//
//        try {
//
//            // 打开Word文档，并读取内容
//
//            in = new FileInputStream(filePath);
//
//            doc = new XWPFDocument(in);
//
//            for (XWPFParagraph paragraph : doc.getParagraphs()) {
//                List runs = paragraph.getRuns();
//
//                for (XWPFRun run : runs) {
//
//                    String text = run.getText(0);
//
//                    if (text != null && text.contains(oldStr)) {
//
//                        text = text.replace(oldStr, newStr);
//
//                        run.setText(text, 0);
//
//                    }
//
//                }
//
//            }
//
//            // 保存修改后的Word文档
//
//            FileOutputStream out = new FileOutputStream(filePath);
//
//            doc.write(out);
//
//            out.close();
//
//        } catch (Exception e) {
//
//            e.printStackTrace();
//
//        } finally {
//
//            try {
//
//                if (doc != null) {
//
//                    doc.close();
//
//                }
//
//                if (in != null) {
//
//                    in.close();
//
//                }
//
//            } catch (IOException e) {
//
//                e.printStackTrace();
//
//            }
//
//        }
//
//    }
//
//}
//
//
////    public static void downloadWord(String wordModePath, String wordModeFile) {
////        try {
////            // 1. 获取替换参数
////            Map<String, Object> wordData = initWordMap();
////
////            // 2. 设置配置内容
////            // 设置版本
////            Configuration configuration = new Configuration(new Version(VERSION));
////            // 指定加载Word模板的路径
////            configuration.setDirectoryForTemplateLoading(new File(wordModePath));
////            // 以UTF-8的编码格式，读取模板文档
////            Template template = configuration.getTemplate(wordModeFile, CHARSET);
////
////            // 3. 输出文档路径及名称
////            File outFile = new File(wordModePath  + "temp.doc");
////            Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), CHARSET), 10240);
////            // 输出
////            template.process(wordData, writer);
////            writer.flush();
////            writer.close();
////            System.out.println("员工信息导出已完成");
////
////        } catch (TemplateException e) {
////            e.printStackTrace();
////        } catch (IOException e) {
////            e.printStackTrace();
////        }
////    }
////
////    private static Map<String, Object> initWordMap() {
//////        List<UserBean> userList = new ArrayList<UserBean>();
//////        userList.add(new UserBean("用户1", "10", "171", "男"));
//////        userList.add(new UserBean("用户2", "20", "172", "女"));
//////        userList.add(new UserBean("用户3", "30", "173", "男"));
//////        userList.add(new UserBean("用户4", "40", "174", "女"));
//////        userList.add(new UserBean("用户3", "50", "175", "男"));
////
////        Map<String, Object> wordData = new HashMap<String, Object>();
////        wordData.put("${delegate_name}", "作者1");
//////        wordData.put("age", "60");
//////        wordData.put("high", "177");
//////        wordData.put("userList", userList);
////
////        return wordData;
////    }
